<!--
* @FileDescription: 人员联动
* @Author: yuec621@outlook.com
* @Date: 2025-07-11 12:48:22
 * @LastEditors: Please set LastEditors
 * @LastEditTime: 2025-07-11 15:19:50
-->
<template>
    <div class="pagestyle">
        <list_controller ref="zujianname" :options="state.options" :noprintDownShow="true">
            <template v-slot:opraCurdBtnlist="row">
                <span>
                    <el-button class="tableFontSize" type="primary" link size="small" @click="editBtn(row.row.row)">编辑
                    </el-button>
                    <el-button class="tableFontSize" type="primary" link size="small" @click="deleteBtn(row.row.row)">删除
                    </el-button>
                </span>
            </template>
            <template v-slot:opraCurdBtnAll>
                <span v-if="userStore.modify" :class="state.addModal ? 'listInfoBtn active' : 'listInfoBtn'"
                    @click="addBtn('mul')">
                    <svg-icon :class="state.addModal ? 'active' : ''" class-name="search-icon" icon-class="xinzeng" />
                    新增
                </span>
                <span v-if="userStore.modify" :class="'listInfoBtn'" @click="deleteBtn('mul')">
                    <svg-icon class-name="search-icon" icon-class="shanchu" />
                    删除
                </span>
            </template>
            <template v-slot:selectNamelist>
                人员联动
            </template>
        </list_controller>
        <!-- 新增弹框 -->
        <vxe-modal esc-closable destroy-on-close :lock-view="false" :width="1000" :height="auto"
            v-model="state.addModal" resize :mask="true" showFooter>
            <template #title>
                <div class="w100 h100 fsc mask_title">{{state.modalTitle}}</div>
            </template>
            <template #default>
                <div class="form_box">
                    <el-form ref="formRef" :model="state.formData" :rules="state.rules" label-position="left">
                        <el-row :gutter="20">
                            <el-col :span="8">
                                <el-form-item label="人员联动名称" prop="personnelLinkageName">
                                    <el-input v-model="state.formData.personnelLinkageName" placeholder="请输入">
                                    </el-input>
                                </el-form-item>
                            </el-col>
                            <el-col :span="8">
                                <el-form-item label="分站号" prop="stationCode">
                                    <el-select ref="stationCodeRef" filterable v-model="state.formData.stationCode"
                                        placeholder="请选择" @change="stationModelChange($event)">
                                        <el-option v-for="item in state.stationmodelList" :key="item.commonField"
                                            :label="item.commonField" :value="item.commonField">
                                        </el-option>
                                    </el-select>
                                </el-form-item>
                            </el-col>
                            <el-col :span="24">
                                <p style="text-align: right;">
                                    <el-button type="primary" :disabled="!state.formData.stationCode"
                                        @click="addTableList">
                                        <svg-icon class-name="search-icon" icon-class="xinzeng" />新增</el-button>
                                </p>
                                <vxe-table :cell-config="{height: 60}" height="300" class="w100"
                                    :data="state.formData.nodeList" border="inner">
                                    <vxe-column type="seq" width="60" title="序号">
                                    </vxe-column>
                                    <vxe-column field="sensorName" width="142" title="设备名">
                                        <template #default="{row,rowIndex}">
                                            <el-form-item style="margin-top:5px"
                                                :prop="`nodeList[${rowIndex}]sensorName`"
                                                :rules="state.rules.sensorName">
                                                <el-cascader :ref="'sensorNameref'+rowIndex" v-model="row.sensorName"
                                                    :options="state.sensorNamelList" clearable
                                                    :props="{value: 'aggregationName',label: 'commonField', checkStrictly: true,emitPath: false}"
                                                    @change="templateTreeChange(rowIndex)" />
                                            </el-form-item>
                                        </template>
                                    </vxe-column>
                                    <vxe-column field="pointName" width="142" title="测点编号">
                                        <template #default="{row,rowIndex}">
                                            <el-form-item style="margin-top:5px"
                                                :prop="row.pointNodeList==null?'':`nodeList[${rowIndex}]pointId`"
                                                :rules="state.rules.pointId">
                                                <el-select :disabled="row.pointNodeList==null" clearable filterable
                                                    @change="pointIdChange($event,rowIndex)" v-model="row.pointId"
                                                    placeholder="请选择">
                                                    <el-option v-for="item in row.pointNodeList" :key="item.pointId"
                                                        :label="item.pointId" :value="item.pointId">
                                                    </el-option>
                                                </el-select>
                                            </el-form-item>
                                        </template>
                                    </vxe-column>
                                    <vxe-column field="alarmModel" width="142" title="报警模式">
                                        <template #default="{row,rowIndex}">
                                            <el-form-item style="margin-top:5px"
                                                :prop="row.pointNodeList==null?'':`nodeList[${rowIndex}]alarmModel`"
                                                :rules="state.rules.alarmModel">
                                                <el-select clearable filterable :disabled="row.pointNodeList==null"
                                                    v-model="row.alarmModel" placeholder="请选择">
                                                    <el-option v-for="item in row.alarmModelList" :key="item"
                                                        :label="item" :value="item">
                                                    </el-option>
                                                </el-select>
                                            </el-form-item>
                                        </template>
                                    </vxe-column>
                                    <vxe-column field="upperAlarmValue" width="142" title="上限报警值">
                                        <template #default="{row,rowIndex}">
                                            <el-form-item style="margin-top:5px"
                                                :prop="row.pointNodeList==null||row.alarmModel=='下限报警'
                                                ||row.pointId&&row.pointId.includes('D')?'':`nodeList[${rowIndex}]upperAlarmValue`"
                                                :rules="state.rules.upperAlarmValue">
                                                <el-input :disabled="row.pointNodeList==null||row.alarmModel=='下限报警'
                                                ||row.pointId&&row.pointId.includes('D')" v-model="row.upperAlarmValue"
                                                    placeholder="请输入">
                                                </el-input>
                                            </el-form-item>
                                        </template>
                                    </vxe-column>
                                    <vxe-column field="upperRelieveValue" width="142" title="上限解报值">
                                        <template #default="{row,rowIndex}">
                                            <el-form-item style="margin-top:5px"
                                                :prop="row.pointNodeList==null||row.alarmModel=='下限报警'
                                                ||row.pointId&&row.pointId.includes('D')?'':`nodeList[${rowIndex}]upperRelieveValue`"
                                                :rules="state.rules.upperRelieveValue">
                                                <el-input :disabled="row.pointNodeList==null||row.alarmModel=='下限报警'
                                                ||row.pointId&&row.pointId.includes('D')"
                                                    v-model="row.upperRelieveValue" placeholder="请输入">
                                                </el-input>
                                            </el-form-item>
                                        </template>
                                    </vxe-column>
                                    <vxe-column field="lowerAlarmValue" width="142" title="下限报警值">
                                        <template #default="{row,rowIndex}">
                                            <el-form-item style="margin-top:5px"
                                                :prop="row.pointNodeList==null||row.alarmModel=='上限报警'
                                                ||row.pointId&&row.pointId.includes('D')?'':`nodeList[${rowIndex}]lowerAlarmValue`"
                                                :rules="state.rules.lowerAlarmValue">
                                                <el-input :disabled="row.pointNodeList==null||row.alarmModel=='上限报警'
                                                ||row.pointId&&row.pointId.includes('D')" v-model="row.lowerAlarmValue"
                                                    placeholder="请输入">
                                                </el-input>
                                            </el-form-item>
                                        </template>
                                    </vxe-column>
                                    <vxe-column field="lowerRelieveValue" width="142" title="下限解报值">
                                        <template #default="{row,rowIndex}">
                                            <el-form-item style="margin-top:5px"
                                                :prop="row.pointNodeList==null||row.alarmModel=='上限报警'
                                                ||row.pointId&&row.pointId.includes('D')?'':`nodeList[${rowIndex}]lowerRelieveValue`"
                                                :rules="state.rules.lowerRelieveValue">
                                                <el-input :disabled="row.pointNodeList==null||row.alarmModel=='上限报警'
                                                ||row.pointId&&row.pointId.includes('D')"
                                                    v-model="row.lowerRelieveValue" placeholder="请输入">
                                                </el-input>
                                            </el-form-item>
                                        </template>
                                    </vxe-column>
                                    <vxe-column field="durationTime" width="142" title="持续时间(秒)">
                                        <template #default="{row,rowIndex}">
                                            <el-form-item style="margin-top:5px"
                                                :prop="`nodeList[${rowIndex}]durationTime`"
                                                :rules="state.rules.durationTime">
                                                <el-input oninput="value=value.replace(/[^0-9]/g,'')"
                                                    v-model="row.durationTime" placeholder="请输入">
                                                </el-input>
                                            </el-form-item>
                                        </template>
                                    </vxe-column>
                                    <vxe-column field="ipAddress" width="142" title="远端IP地址">
                                        <template #default="{row,rowIndex}">
                                            <el-form-item style="margin-top:5px"
                                                :prop="`nodeList[${rowIndex}]ipAddress`" :rules="state.rules.ipAddress">
                                                <el-input v-model="row.ipAddress" placeholder="请输入">
                                                </el-input>
                                            </el-form-item>
                                        </template>
                                    </vxe-column>
                                    <vxe-column field="port" width="142" title="端口">
                                        <template #default="{row,rowIndex}">
                                            <el-form-item style="margin-top:5px" :prop="`nodeList[${rowIndex}]port`"
                                                :rules="state.rules.port">
                                                <el-input v-model.number="row.port" placeholder="请输入">
                                                </el-input>
                                            </el-form-item>
                                        </template>
                                    </vxe-column>
                                    <vxe-column field="remoteStationCode" width="142" title="远端分站号">
                                        <template #default="{row,rowIndex}">
                                            <el-form-item style="margin-top:5px"
                                                :prop="`nodeList[${rowIndex}]remoteStationCode`"
                                                :rules="state.rules.remoteStationCode">
                                                <el-input v-model="row.remoteStationCode"
                                                    oninput="value=value.replace(/[^0-9]/g,'')" placeholder="请输入">
                                                </el-input>
                                            </el-form-item>
                                        </template>
                                    </vxe-column>
                                    <vxe-column field="probeNum" width="142" title="探头号">
                                        <template #default="{row,rowIndex}">
                                            <el-form-item style="margin-top:5px" :prop="`nodeList[${rowIndex}]probeNum`"
                                                :rules="state.rules.probeNum">
                                                <el-input v-model="row.probeNum"
                                                    oninput="value=value.replace(/[^0-9]/g,'')" placeholder="请输入">
                                                </el-input>
                                            </el-form-item>
                                        </template>
                                    </vxe-column>
                                    <vxe-column field="cardOne" width="142" title="卡号1">
                                        <template #default="{row,rowIndex}">
                                            <el-form-item style="margin-top:5px" :prop="`nodeList[${rowIndex}]cardOne`"
                                                :rules="state.rules.cardOne">
                                                <el-input v-model.number="row.cardOne" placeholder="请输入">
                                                </el-input>
                                            </el-form-item>
                                        </template>
                                    </vxe-column>
                                    <vxe-column field="cardTwo" width="142" title="卡号2">
                                        <template #default="{row,rowIndex}">
                                            <el-form-item style="margin-top:5px" :prop="`nodeList[${rowIndex}]cardTwo`"
                                                :rules="state.rules.cardTwo">
                                                <el-input v-model.number="row.cardTwo" placeholder="请输入">
                                                </el-input>
                                            </el-form-item>
                                        </template>
                                    </vxe-column>
                                    <vxe-column field="cardThree" width="142" title="卡号3">
                                        <template #default="{row,rowIndex}">
                                            <el-form-item style="margin-top:5px"
                                                :prop="`nodeList[${rowIndex}]cardThree`" :rules="state.rules.cardThree">
                                                <el-input v-model.number="row.cardThree" placeholder="请输入">
                                                </el-input>
                                            </el-form-item>
                                        </template>
                                    </vxe-column>
                                    <vxe-column field="cardFour" width="142" title="卡号4">
                                        <template #default="{row,rowIndex}">
                                            <el-form-item style="margin-top:5px" :prop="`nodeList[${rowIndex}]cardFour`"
                                                :rules="state.rules.cardFour">
                                                <el-input v-model.number="row.cardFour" placeholder="请输入">
                                                </el-input>
                                            </el-form-item>
                                        </template>
                                    </vxe-column>
                                    <vxe-column field="cardFive" width="142" title="卡号5">
                                        <template #default="{row,rowIndex}">
                                            <el-form-item style="margin-top:5px" :prop="`nodeList[${rowIndex}]cardFive`"
                                                :rules="state.rules.cardFive">
                                                <el-input v-model.number="row.cardFive" placeholder="请输入">
                                                </el-input>
                                            </el-form-item>
                                        </template>
                                    </vxe-column>
                                    <vxe-column field="infoContent" width="142" title="信息内容">
                                        <template #default="{row,rowIndex}">
                                            <el-form-item style="margin-top:5px"
                                                :prop="`nodeList[${rowIndex}]infoContent`"
                                                :rules="state.rules.infoContent">
                                                <el-input v-model="row.infoContent" placeholder="请输入">
                                                </el-input>
                                            </el-form-item>
                                        </template>
                                    </vxe-column>
                                    <vxe-column field="powerOutage" width="80" title="断线断电">
                                        <template #default="{row,rowIndex}">
                                            <el-form-item style="margin-top:5px"
                                                :prop="`nodeList[${rowIndex}]powerOutage`"
                                                :rules="state.rules.powerOutage">
                                                <el-checkbox v-model="row.powerOutage" size="large" />
                                            </el-form-item>
                                        </template>
                                    </vxe-column>
                                    <vxe-column title="操作" width="80">
                                        <template #default="{row,rowIndex}">
                                            <el-button type="text" @click="delTableListClick(rowIndex)">删除</el-button>
                                        </template>
                                    </vxe-column>
                                </vxe-table>
                            </el-col>
                            <el-col :span="24" style="margin-top: 10px;">
                                <el-form-item label="备注">
                                    <el-input v-model="state.formData.remark" type="textarea" placeholder="请输入">
                                    </el-input>
                                </el-form-item>
                            </el-col>
                            <el-col :span="24">
                                注释：“持续时间”设置为0表示持续报警；
                                “探头号”设置为0表示所有探头；
                                “卡号1”设置为0表示所有卡号。
                            </el-col>
                        </el-row>
                    </el-form>
                </div>
            </template>
            <template #footer>
                <el-button @click="cancel">取消</el-button>
                <el-button type="primary" @click="submitForm">
                    确定
                </el-button>
            </template>
        </vxe-modal>
    </div>
</template>
<script setup>
    import list_controller from "@/components/commonCom/list_controller";
    import {
        computed,
        nextTick,
        reactive
    } from "vue";
    import {
        ElMessage,
        ElMessageBox
    } from 'element-plus'
    import {
        table_headers
    } from '@/components/commonCom/table_headers';
    import axios from "@/utils/request"
    import usePagesStore from '@/store/modules/pages'
    import useUserStore from "@/store/modules/user";
    const userStore = useUserStore();
    const {
        proxy
    } = getCurrentInstance();
    const store = usePagesStore()
    const router = useRouter();
    const upload = ref(null)
    /** 自定义校验 */
    // ip
    const validateip = (rule, value, callback) => {
        let reg =
            /^(1\d{2}|2[0-4]\d|25[0-5]|[1-9]\d|[0-9])\.((1\d{2}|2[0-4]\d|25[0-5]|[1-9]\d|\d)\.){2}(1\d{2}|2[0-4]\d|25[0-5]|[1-9]\d|\d)$/
        if (!reg.test(value))
            return callback(new Error("请输入正确的IP"));
        callback();
    }
    // 端口
    const validatePass = (rule, value, callback) => {
        let reg = new RegExp(/^([0-9]|[1-9]\d{1,3}|[1-5]\d{4}|6[0-4]\d{4}|65[0-4]\d{2}|655[0-2]\d|6553[0-5])$/);
        if (!reg.test(value))
            return callback(new Error("请输入正确端口(0-65535)"));
        callback();
    }
    const validatecard = (rule, value, callback) => {
        let reg = new RegExp(/^([0-9]|[1-9]\d{1,3}|[1-5]\d{4}|9[0-4]\d{4}|99[0-4]\d{2}|999[0-2]\d|9999[0-9])$/);
        if (!reg.test(value))
            return callback(new Error("请输入正确卡号(0-99999)"));
        callback();
    }
    let state = reactive({
        pointNodeList: [],
        alarmModelList: ['上限报警', '下限报警', '上下限报警'],
        options: {
            tableheads: computed(() => table_headers.personnelLinkage),
            queryList: {
                dropdownUrl: '',
                querys: []
            },
            dataUrl: '/personnelLinkage/list',
            delUrl: '/personnelLinkage/batchDelete',
            addUrl: '/personnelLinkage/addRecord',
            descUrl: '/personnelLinkage/detail',
            editUrl: '/personnelLinkage/updateRecord',
        },
        // 表单
        addModal: false,
        modalTitle: '新增分站类型',
        formRef: null,
        formData: {
            nodeList: [{
                powerOutage: false
            }]
        },
        rules: {
            personnelLinkageName: [{
                required: true,
                message: '请输入人员名称',
                trigger: 'blur'
            }],
            stationCode: [{
                required: true,
                message: '请输入分站号',
                trigger: 'change'
            }],
            sensorName: [{
                required: true,
                message: "请选择",
                trigger: "change",
            }],
            pointId: [{
                required: true,
                message: "请选择",
                trigger: "change",
            }],
            alarmModel: [{
                required: true,
                message: "请选择",
                trigger: "change",
            }],
            upperAlarmValue: [{
                required: true,
                message: "请输入",
                trigger: "blur",
            }],
            upperRelieveValue: [{
                required: true,
                message: "请输入",
                trigger: "blur",
            }],
            lowerAlarmValue: [{
                required: true,
                message: "请输入",
                trigger: "blur",
            }],
            lowerRelieveValue: [{
                required: true,
                message: "请输入",
                trigger: "blur",
            }],
            durationTime: [{
                required: true,
                message: "请输入",
                trigger: "blur",
            }],
            ipAddress: [{
                required: true,
                message: "请输入",
                trigger: "blur",
            }, {
                validator: validateip,
                trigger: 'blur'
            }],
            port: [{
                    required: true,
                    message: "请输入",
                    trigger: "blur",
                }, {
                    type: 'number',
                    message: '请输入数字',
                    trigger: 'blur'
                },
                {
                    validator: validatePass,
                    trigger: 'blur'
                }
            ],
            remoteStationCode: [{
                required: true,
                message: "请输入",
                trigger: "blur",
            }],
            priority: [{
                required: true,
                message: "请输入",
                trigger: "blur",
            }],
            probeNum: [{
                required: true,
                message: "请输入",
                trigger: "blur",
            }],
            cardOne: [{
                    required: true,
                    message: "请输入",
                    trigger: "blur",
                }, {
                    type: 'number',
                    message: '请输入数字',
                    trigger: 'blur'
                },
                {
                    validator: validatecard,
                    trigger: 'blur'
                }
            ],
            cardTwo: [{
                    required: true,
                    message: "请输入",
                    trigger: "blur",
                }, {
                    type: 'number',
                    message: '请输入数字',
                    trigger: 'blur'
                },
                {
                    validator: validatecard,
                    trigger: 'blur'
                }
            ],
            cardThree: [{
                    required: true,
                    message: "请输入",
                    trigger: "blur",
                }, {
                    type: 'number',
                    message: '请输入数字',
                    trigger: 'blur'
                },
                {
                    validator: validatecard,
                    trigger: 'blur'
                }
            ],
            cardFour: [{
                    required: true,
                    message: "请输入",
                    trigger: "blur",
                }, {
                    type: 'number',
                    message: '请输入数字',
                    trigger: 'blur'
                },
                {
                    validator: validatecard,
                    trigger: 'blur'
                }
            ],
            cardFive: [{
                    required: true,
                    message: "请输入",
                    trigger: "blur",
                }, {
                    type: 'number',
                    message: '请输入数字',
                    trigger: 'blur'
                },
                {
                    validator: validatecard,
                    trigger: 'blur'
                }
            ],
            infoContent: [{
                required: true,
                message: "请输入",
                trigger: "blur",
            }],
            powerOutage: [{
                required: true,
                message: "请选择",
                trigger: "change",
            }]
        },
        editId: undefined,
        stationmodelList: [],
        sensorNamelList: []
    })


    // 新增按钮
    function addBtn(row) {
        state.modalTitle = '新增人员联动'
        state.addModal = true
        state.formData = {}
        state.formData.nodeList = [{
            powerOutage: false
        }]
        state.editId = undefined
        state.sensorNamelList=[]
    }

    // 编辑按钮
    function editBtn(row) {
        state.modalTitle = '编辑人员联动'
        state.addModal = true
        axios.post(state.options.descUrl, {
            id: row.id
        }).then(res => {
            if (res.code == 200) {
                state.formData = res.data
                state.editId = res.data.id
                state.stationmodelList.forEach(item => {
                    if (res.data.stationCode == item.commonField) {
                        state.sensorNamelList = item.children
                    }
                })
                if (res.data.nodeList.length > 0) {
                    res.data.nodeList.forEach((itemnode, index) => {
                        nextTick(() => {
                            if (proxy.$refs['sensorNameref' + index].getCheckedNodes()[0]) {
                                state.formData.nodeList[index].pointNodeList = proxy.$refs[
                                        'sensorNameref' + index].getCheckedNodes()[0]
                                    .data.nodeList
                                if (proxy.$refs['sensorNameref' + index].getCheckedNodes()[0]
                                    .data.nodeList == null) {
                                    state.formData.nodeList[index].alarmModel = proxy.$refs[
                                            'sensorNameref' + index].getCheckedNodes()[0]
                                        .value
                                    state.formData.nodeList[index].alarmModelList = []
                                } else {
                                    state.formData.nodeList[index].pointNodeList.forEach(
                                        itemn => {
                                            if (itemn.flag == 'A') {
                                                state.formData.nodeList[index]
                                                    .alarmModelList = ['上限报警', '下限报警',
                                                        '上下限报警'
                                                    ]
                                            } else {
                                                state.formData.nodeList[index]
                                                    .alarmModelList = [itemn.highShow +
                                                        '报警', itemn.lowShow + '报警'
                                                    ]
                                            }
                                        })
                                }
                            }
                        })
                    })
                }


            }
        })
    }

    function deleteBtn(row) {
        let ids = []
        if (row != 'mul') {
            ids = [row.id]
        } else {
            if (store.records.length > 0) {
                ids = store.records.map(item => {
                    return item.id
                })
            } else {
                proxy.$modal.msgSuccess('请先勾选所要删除数据!');
            }
        }
        if (ids.length > 0) {
            ElMessageBox.confirm(
                    '确定要删除该数据吗?',
                    '温馨提示', {
                        confirmButtonText: '确定',
                        cancelButtonText: '取消',
                        type: 'warning',
                    }
                )
                .then(() => {
                    axios.post(state.options.delUrl, ids).then(res => {
                        if (res.code == 200) {
                            proxy.$refs['zujianname'].getData()
                            state.addModal = false
                            ElMessage({
                                type: 'success',
                                message: res.msg,
                            })
                            store.records = []
                        }
                    })

                })
                .catch(() => {
                    ElMessage({
                        type: 'info',
                        message: '删除取消',
                    })
                })
        }
    }
    /** 提交按钮 */
    function submitForm() {
        proxy.$refs["formRef"].validate(valid => {
            if (valid) {
                if (state.editId) {
                    state.formData.id = state.editId
                    axios.post(state.options.editUrl, state.formData).then(res => {
                        if (res.code == 200) {
                            proxy.$refs['zujianname'].getData()
                            state.addModal = false
                            proxy.$modal.msgSuccess(res.msg);
                        }
                    })
                } else {
                    axios.post(state.options.addUrl, state.formData).then(res => {
                        if (res.code == 200) {
                            proxy.$refs['zujianname'].getData()
                            state.addModal = false
                            proxy.$modal.msgSuccess(res.msg);
                        }
                    })
                }
            }
        })
    }

    function cancel() {
        state.addModal = false
    }

    function addTableList() {
        state.formData.nodeList.push({
            powerOutage: false
        })
    }

    function delTableListClick(index) {
        state.formData.nodeList.splice(index, 1)
    }

    function getsubstationmodelList() {
        axios.post('broadcastLinkage/getStationTree', {}).then(res => {
            state.stationmodelList = res.data
        })
    }

    function stationModelChange(val) {
        state.stationmodelList.forEach(item => {
            if (item.commonField == val) {
                state.formData.nodeList = [{
                    powerOutage: false
                }]
                state.sensorNamelList = item.children
            }
        })
    }

    function templateTreeChange(index) {
        state.formData.nodeList[index].alarmModel = undefined
        state.formData.nodeList[index].pointId = undefined
        state.formData.nodeList[index].upperAlarmValue = undefined
        state.formData.nodeList[index].upperRelieveValue = undefined
        state.formData.nodeList[index].lowerAlarmValue = undefined
        state.formData.nodeList[index].lowerRelieveValue = undefined
        if (proxy.$refs['sensorNameref' + index].getCheckedNodes()[0]) {
            state.formData.nodeList[index].pointNodeList = proxy.$refs['sensorNameref' + index].getCheckedNodes()[0]
                .data.nodeList
            if (proxy.$refs['sensorNameref' + index].getCheckedNodes()[0].data.nodeList == null) {
                state.formData.nodeList[index].alarmModel = proxy.$refs['sensorNameref' + index].getCheckedNodes()[0]
                    .value
                state.formData.nodeList[index].alarmModelList = []
            }
        }
    }

    function pointIdChange(val, index) {
        state.formData.nodeList[index].pointNodeList.forEach(item => {
            if (item.pointId == val) {
                if (item.flag == 'A') {
                    state.formData.nodeList[index].alarmModelList = ['上限报警', '下限报警', '上下限报警']
                } else {
                    state.formData.nodeList[index].alarmModelList = [item.highShow + '报警', item.lowShow + '报警']
                }
            }
        })
    }
    getsubstationmodelList()
</script>
<style lang="scss" scoped>

</style>